<cfmodule template="../../tag/layout.cfm">
<div id="grid"></div>
<div id="toolbar" style="display: none;">
	<form id="searchForm">
		<table>
			<tr>
				<td>用户名</td>
				<td><input name="loginname" style="width: 180px;" /></td>
				<td>创建时间</td>
				<td>
					<input name="created_ge"  class="easyui-datebox" style="width:100px"/>
					-
					<input name="created_le"  class="easyui-datebox" style="width:100px"/>
				</td>
				<td>
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'ext-icon-zoom',plain:true" onclick="grid.datagrid('load',fw.serializeObject($('#searchForm')));">过滤</a>
					<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'ext-icon-zoom_out',plain:true" onclick="$('#searchForm input').val('');grid.datagrid('load',{});">重置过滤</a>
				</td>
			</tr>
		</table>
	</form>
	<table>
		<tr>
			<td>
				<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'ext-icon-note_add',plain:true" onclick="addFun();">添加</a>
			</td>
		</tr>
	</table>
</div>
</cfmodule>
<script type="application/javascript">
//删除操作
var removeFun = function(id) {
    parent.$.messager.confirm('询问', '您确定要删除此记录？',
    function(r) {
        if (r) {
            $.post('?action=members.delete', {
                id: id
            },
            function(result) {
                grid.datagrid('reload');
            },
            'json');
        }
    });
};

var lockFun = function(id) {
    parent.$.messager.confirm('询问', '您确定要锁定/解锁该用户？',
    function(r) {
        if (r) {
            $.post('?action=members.lock', {
                id: id
            },
            function(result) {
                grid.datagrid('reload');
            },
            'json');
        }
    });
};

var resetLoginPwdFun = function(id) {
    parent.$.messager.confirm('询问', '您确定要重置该用户登陆密码为111111？',
    function(r) {
        if (r) {
            $.post('?action=members.resetLoginPwd', {
                id: id
            },
            function(result) {
                grid.datagrid('reload');
            },
            'json');
        }
    });
};

var resetPayPwdFun = function(id) {
    parent.$.messager.confirm('询问', '您确定要重置该用户交易密码为111111？',
    function(r) {
        if (r) {
            $.post('?action=members.resetPayPwd', {
                id: id
            },
            function(result) {
                grid.datagrid('reload');
            },
            'json');
        }
    });
};


//查看操作
var showFun = function(id) {
    var dialog = parent.fw.modalDialog({
        title: '查看记录',
        url: '?action=members.form&id=' + id,
        buttons: [{
            text: '关闭窗口',
            handler: function() {
                dialog.find('iframe').get(0).contentWindow.closeDialog(dialog);
            }
        }]
    });
};


//新增操作
var addFun = function() {
    var dialog = parent.fw.modalDialog({
        title: '新增记录',
        url: '?action=members.form',
        buttons: [
        {
            text: '新增记录',
            handler: function() {
                dialog.find('iframe').get(0).contentWindow.submitForm(dialog, grid, parent.$);
            }
        },{
            text: '关闭窗口',
            handler: function() {
               dialog.find('iframe').get(0).contentWindow.closeDialog(dialog);
            }
        }]
    });
}
//修改操作
var editFun = function(id) {
    var dialog = parent.fw.modalDialog({
        title: '修改记录',
        url: '?action=members.form&id=' + id,
        buttons: [
        {
            text: '修改记录',
            handler: function() {
                dialog.find('iframe').get(0).contentWindow.submitForm(dialog, grid, parent.$);
            }
        },{
            text: '关闭窗口',
            handler: function() {
                dialog.find('iframe').get(0).contentWindow.closeDialog(dialog);
            }
        }]
    });
};


$(function(){
	//列表操作
	var gird;
	grid = $('#grid').datagrid({
		fit: true,
		border:false,
		collapsible:false,
		pagination:true,
		singleSelect:true,
		rownumbers:true,
		sortName:'id',
		idField:'id',
		checkOnSelect:false,
		sortOrder:'desc',
		toolbar : '#toolbar',
		url:'?action=members.list',
		columns:[[
			{field:'id',title:'ID',width:40,sortable:true},
			{field:'loginname',title:'用户名称',width:80,sortable:true},
			{field:'sex',title:'性别',width:50,sortable:true,align:'center'},
			{field:'mobile',title:'移动电话',width:100,sortable:true},
			{field:'address',title:'联系地址',width:300,sortable:true},
			{field:'money',title:'账户资金',width:80,sortable:true,align:'right'},
			{field:'frozenmoney',title:'冻结资金',width:80,sortable:true,align:'right'},
			{field:'state',title:'用户状态',width:60,sortable:true,align:'center',
				formatter : function(value, row) {
					var str = '';
					if(value==0){
						str ='锁定';
					}else if(value ==1){
						str = '有效';
					}else{
						str = '未激活';
					}
					return str;
				}
			},
			{field:'created',title:'添加时间',width:80,align:'center',sortable:true},
			{field:'edited',title:'修改时间',width:80,align:'center',sortable:true},
			{
				title : '操作',
				field : 'action',
				align: 'center',
				width : '120',
				formatter : function(value, row) {
					var str = '';
						str += fw.formatString(' <img class="iconImg ext-icon-note" title="查看" onclick="showFun(\'{0}\');"/>', row.id);
						str += fw.formatString(' <img class="iconImg ext-icon-note_edit" title="编辑" onclick="editFun(\'{0}\');"/>', row.id);
						str += fw.formatString(' <img class="iconImg ext-icon-note_delete" title="删除" onclick="removeFun(\'{0}\');"/>', row.id);
						str += fw.formatString(' <img class="iconImg ext-icon-lock_add" title="锁定/解锁" onclick="lockFun(\'{0}\');"/>', row.id);
						str += fw.formatString(' <img class="iconImg ext-icon-wrench" title="重置登陆密码" onclick="resetLoginPwdFun(\'{0}\');"/>', row.id);
						str += fw.formatString(' <img class="iconImg ext-icon-wrench_orange" title="重置交易密码" onclick="resetPayPwdFun(\'{0}\');"/>', row.id);
					return str;
				}
			}
		]],
		onLoadSuccess : function(data) {
			$('.iconImg').attr('src', fw.pixel_0);
		}
	});


});
</script>